package com.trust.pams.service.redis.pub;

import com.alibaba.fastjson.JSON;
import com.chasonx.common.config.RedisTemplateUtils;
import com.trust.pams.service.redis.config.BaseModel;
import com.trust.pams.service.redis.config.PamsQuoteCaptcha;
import com.trust.pams.service.redis.config.PubSubConfig;
import com.trust.pams.util.UUIDUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;

@Component
public class PubService {

    private static final Logger log = LoggerFactory.getLogger(PubService.class);

    @Autowired
    private RedisTemplateUtils redisTemplateUtils;

    public boolean pubMessage(BaseModel model){
        String token = UUIDUtil.generateUUID();
        //添加到队列
        redisTemplateUtils.getRedisTemplate().opsForSet().add(PubSubConfig.CAPTCHA_MAIL_QUEEN,model);
        //发送topic
        redisTemplateUtils.getRedisTemplate().convertAndSend(PubSubConfig.CAPTCHA_TOPIC, token);
        return true;
    }

}
